package com.xwqkwl.aicode.service;

import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.service.IService;
import com.xwqkwl.aicode.model.dto.app.AppAddRequest;
import com.xwqkwl.aicode.model.dto.app.AppQueryRequest;
import com.xwqkwl.aicode.model.entity.App;
import com.xwqkwl.aicode.model.entity.User;
import com.xwqkwl.aicode.model.vo.AppVO;
import reactor.core.publisher.Flux;

import java.util.List;

/**
 * 应用 服务层。
 *
 * @author <a href="https://gitee.com/xwqkwl">程序员徐伟强</a>
 */
public interface AppService extends IService<App> {

    /**
     * 创建应用
     * @param appAddRequest appAddRequest
     * @param loginUser loginUser
     * @return Long
     */
    Long createApp(AppAddRequest appAddRequest, User loginUser);

    /**
     * 获取应用VO类
     * @param app app
     * @return AppVO
     */
    AppVO getAppVO(App app);

    /**
     * 获取mybatis的查询对象
     * @param appQueryRequest appQueryRequest
     * @return QueryWrapper
     */
    QueryWrapper getQueryWrapper(AppQueryRequest appQueryRequest);

    /**
     * 获取应用VO列表
     * @param appList appList
     * @return List<AppVO>
     */
    List<AppVO> getAppVOList(List<App> appList);

    /**
     * 聊天生成代码
     * @param appId appId
     * @param message message
     * @param loginUser loginUser
     * @return Flux<String>
     */
    Flux<String> chatToGenCode(Long appId, String message, User loginUser);

    /**
     * 部署应用
     * @param appId appId
     * @param loginUser loginUser
     * @return String
     */
    String deployApp(Long appId, User loginUser);

    /**
     * 异步生成应用截图
     * @param appId appId
     * @param appUrl appUrl
     */
    void generateAppScreenshotAsync(Long appId, String appUrl);
}
